year=eval(input())
month=eval(input())
day=eval(input())
isleapyear=(year%400==0)or(year%100!=0 and year%4==0)
monthdays=[31,28,31,30,31,30,31,31,30,31,30,31]
if isleapyear:
    monthdays[1]=29
dayofyear=sum(monthdays[:month-1])+day
print(dayofyear)